(deftemplate animale
    (slot nume)
    (slot mediuViata)
    (slot modViata)
    (slot regimAlimentar)
    (slot zona)
    (slot consumatorDe)
    (slot consumatDe)
)

(assert (animale (nume broasca)(mediuViata semiacvatic)(modViata diurn)(regimAlimentar omnivor)
    (zona mediteraneana)(consumatorDe lacuste)(consumatDe om)))
(assert (animale (nume foca)(mediuViata acvatic)(modViata diurn)(regimAlimentar omnivor)
    (zona polara)(consumatorDe pesti)(consumatDe urs)))
(assert (animale (nume urs)(mediuViata semiacvatic)(modViata diurn)(regimAlimentar omnivor)
    (zona polara)(consumatorDe foca)(consumatDe urs)))
(assert (animale (nume tigru)(mediuViata terestru)(modViata diurn)(regimAlimentar carnivor)
    (zona deserturilor)(consumatorDe capre)(consumatDe leu)))
(assert (animale (nume leu)(mediuViata terestru)(modViata diurn)(regimAlimentar carnivor)
    (zona deserturilor)(consumatorDe capre)(consumatDe leu)))
(assert (animale (nume hiena)(mediuViata terestru)(modViata nocturn)(regimAlimentar omnivor)
    (zona mediteraneana)(consumatorDe viezure)(consumatDe leu)))
(assert (animale (nume liliac)(mediuViata terestru)(modViata nocturn)(regimAlimentar ierbivor)
    (zona mediteraneana)(consumatorDe lapte)(consumatDe pisica)))

(defrule rule1
    (declare (salience 31))
    (animale (nume ?n)(mediuViata semiacvatic))
    
    => 
    (printout t "Animalul " ?n " traieste intr-un mediu semiacvatic." crlf)
 )
(defrule rule2
    (declare (salience 22))
    (animale (nume ?n)(regimAlimentar ierbivor)(zona mediteraneana))
    
    => 
    (printout t "Animalul " ?n " este ierbivor si traieste intr-un zona mediteraneana." crlf)
 )
(defrule rule3a
    (declare (salience 13))
    (animale (nume ?n)(consumatorDe ?x))
        
    => 
    (printout t "(" ?n ", " ?x ")"crlf)
 )
(defrule rule3b
    (declare (salience 6))
    (animale (nume ?n)(consumatDe ?x))
        
    => 
    (printout t "(" ?x ", " ?n ")"crlf)
 )
(defrule rule4
    (declare (salience 5))
    (animale (nume ?n)(zona ?z &~mediteraneana & ~deserturilor)) 
        
    => 
    (printout t "Animalul " ?n " traieste intr-o zona polara" crlf)
 )

(facts)
(agenda)
(run)

